#ifndef _FT6X36_H
#define _FT6X36_H

#ifdef __cplusplus
extern "C" {
#endif

#include "lv_drv_conf.h"

#include <stdbool.h>
#include "lvgl/src/lv_hal/lv_hal_indev.h"

#if USE_FT6X36

#define FT6X36_I2C_ADDR 0x38 /* 7-bit i2c addr */

#define FTS_REG_INT_CNT                     0x8F
#define FTS_REG_FLOW_WORK_CNT               0x91
#define FTS_REG_WORKMODE                    0x00
#define FTS_REG_WORKMODE_FACTORY_VALUE      0x40
#define FTS_REG_WORKMODE_WORK_VALUE         0x00
#define FTS_REG_ESDCHECK_DISABLE            0x8D
#define FTS_REG_CHIP_ID                     0xA3
#define FTS_REG_CHIP_ID2                    0x9F
#define FTS_REG_POWER_MODE                  0xA5
#define FTS_REG_POWER_MODE_SLEEP_VALUE      0x03
#define FTS_REG_FW_VER                      0xA6
#define FTS_REG_VENDOR_ID                   0xA8
#define FTS_REG_LCD_BUSY_NUM                0xAB
#define FTS_REG_FACE_DEC_MODE_EN            0xB0
#define FTS_REG_FACE_DEC_MODE_STATUS        0x01
#define FTS_REG_IDE_PARA_VER_ID             0xB5
#define FTS_REG_IDE_PARA_STATUS             0xB6
#define FTS_REG_GLOVE_MODE_EN               0xC0
#define FTS_REG_COVER_MODE_EN               0xC1
#define FTS_REG_CHARGER_MODE_EN             0x8B
#define FTS_REG_GESTURE_EN                  0xD0
#define FTS_REG_GESTURE_OUTPUT_ADDRESS      0xD3
#define FTS_REG_MODULE_ID                   0xE3
#define FTS_REG_LIC_VER                     0xE4
#define FTS_REG_ESD_SATURATE                0xED

struct ft6x36_info {
    int irq_pin;
    int rst_pin;
    int i2c_addr;
};

int ft6x36_init(const struct ft6x36_info *info);
bool ft6x36_read(lv_indev_drv_t * indev_drv, lv_indev_data_t *data);
bool ft6x36_vk_read(lv_indev_data_t *data);
void ft6x36_enable_irq(void);
void ft6x36_disable_irq(void);

#endif /* USE_FT6X36 */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* _FT6X36_H */
